<template>
    <div id="app">
        <router-view/>
    </div>
</template>

<script>

    export default {
        name: "App",
        methods: {
            checkLogin() {
                let isLogin = this.COOKIE.get("is_login");
                // console.log(isLogin)
                // 如果是注册的话就不做处理
                if (this.$route.path === '/register') {
                    return;
                }
                if (isLogin !== "1") {
                    this.$router.push({path: "/login"});
                }
            },
        },
        watch: {
            // 监听属性的变化
            "$route.path": function (newPath, oldPath) {
                this.checkLogin();
            },
        },
    };
</script>


<style>
    body,
    html {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
    }

    #app {
        text-align: center;
        color: #2c3e50;
        width: 100%;
        height: 100%;
    }
</style>
